<!DOCTYPE html>
<!-- supperss ALL -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--<base target="_blank">-->
    <base href="." target="_blank">
    <title>搜索</title>
    <meta name="keywords" content="牙疼,口腔知识,口腔资讯,口腔问题">
    <meta name="description" content="牙疼,有贝口腔网为用户提供专业的口腔资讯，口腔知识，口腔问题，口腔卫生等综合服务型网站">
    <link rel="stylesheet" href="./yb_system_css/reset.css">
    <link rel="stylesheet" href="./yb_system_css/commone.css">
    <link rel="stylesheet" href="./yb_system_css/commtwo.css">
    <link rel="stylesheet" href="./yb_system_css/commthree.css">
    <link rel="shortcut icon" href="http://www.hasbei.com/static/images/icon.png" type="image/x-icon">
    <link rel="stylesheet" media="screen and (min-width:481px)" href="./yb_system_css/searchlist.css">
    <link rel="stylesheet" media="screen and (max-width:480px)" href="./yb_system_css/searchlist(1).css">
    <script src="./yb_system_js/hm.js"></script>
    <script type="text/javascript">
        var basePath = "/";
    </script>
    <script src="./yb_system_js/common.js"></script>
    <script src="./yb_system_js/jquery-3.5.1.min.js"></script>
    <script src="./yb_system_js/footfixed.js"></script>
</head>
<body>
<div class="content">
    <div th:replace="public :: header"></div>
    <div class="content-main">
        <div class="search-info">
            <div class="search-content">
                <div class="search-area">
                    <form action="/search" method="get" target="_self">
                        <div class="main-search">
                            <input class="main-search-input" type="text" name="kw" placeholder="请输入相关口腔信息搜索" th:value="${kw}">
                            <label>
                                <img src="./yb_system_picture/search-icon.png">
                                <input type="submit" value="搜索">
                            </label>
                        </div>
                    </form>
                    <div class="search-tuijian" style="display:none">
                        <span>热门搜索</span>
                        <div>
                            <a href="http://www.hasbei.com/">矫正器</a>
                            <a href="http://www.hasbei.com/">矫正器</a>
                            <a href="http://www.hasbei.com/">矫正器</a>
                            <a href="http://www.hasbei.com/">矫正器</a>
                        </div>
                        <span>换一组看看</span>
                    </div>
                </div>
                <div class="search-list">
                    <div class="search-result">为您找到相关结果约[[${mypage.getTotal()}]]个</div>

                    <div class="search-list-item" th:each="list2:${fenye}" th:if="${list2.getType()} == 10" >
                        <div class="search-item-left"><a th:href="@{'/articleDetail?articleId='+${list2.getTid()}}"><img th:src="${list2.getPhoto_path()}"  alt="有贝口腔网"></a></div>
                        <div class="search-item-right">
                            <div class="search-item-text">
                                <div class="search-item-title">
                                    <a th:href="@{'/articleDetail?articleId='+${list2.getTid()}}"><span class="search-item-title-10">[[${list2.getTitle()}]]</span></a>
                                </div>

                                <div class="search-item-desc">
                                    <a th:href="@{'/articleDetail?articleId='+${list2.getTid()}}">[[${list2.getIntroduce()}]]</a>
                                </div>

                                <div class="list-item-info">
                                    <a th:href="@{'/zx/'+${list2.getType_id()}}"><span class="tui-jian">[[${list2.getType_ya()}]]</span></a>
                                    <div class="ping-lun"><a th:href="@{'/articleDetail?articleId='+${list2.getTid()}}"><img src="/static/images/pinglun.png"><span>[[${list2.getCount()}]]评论</span></a></div>
                                    <div class="shou-cang"><a th:href="@{'/articleDetail?articleId='+${list2.getTid()}}"><img src="/static/images/shoucang.png"><span>[[${list2.getCollect_num()}]]收藏</span></a></div>

                                    <div class="yue-du"> <a th:href="@{'/articleDetail?articleId='+${list2.getTid()}}"><img src="/static/images/yuedu.png"><span>[[${list2.getRead_num()}]]阅读</span></a></div>
                                    <span class="dotted">·</span>
                                    <span class="time-before">[[${list2.time}]]</span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="search-list-item" th:each="list2:${fenye}" th:if="${list2.getType()} == 20" >

                        <div class="search-item-text">
                            <div class="search-item-title">
                                <a th:href="@{'/askAnswerDetail?id='+${list2.getTid()}}"><span class="search-item-title-10">[[${list2.getTitle()}]]</span></a>
                            </div>

                            <div class="search-item-desc">
                                <a th:href="@{'/askAnswerDetail?id='+${list2.getTid()}}">[[${list2.getIntroduce()}]]</a>
                            </div>

                            <div class="list-item-info">
                                <a th:href="@{'/qa/'+${list2.getType_id()}}"><span class="tui-jian">[[${list2.getType_ya()}]]</span></a>
                                <a th:href="@{'/personalHomepage?userId='+${list2.getUser_id()}}" class="user-img-name">
                                    <img style="margin-top: -10px;" th:src="${list2.getUser_photo_path()}">
                                    <span class="user-name">[[${list2.getNickname()}]]</span>
                                </a>
                                <div class="ping-lun"><a th:href="@{'/askAnswerDetail?answerId='+${list2.getTid()}}"><img src="/static/images/pinglun.png"><span>[[${list2.getCount()}]]回答</span></a></div>
                                <div class="shou-cang"><a th:href="@{'/askAnswerDetail?answerId='+${list2.getTid()}}"><img src="/static/images/shoucang.png"><span>[[${list2.getCollect_num()}]]收藏</span></a></div>

                                <div class="yue-du"> <a th:href="@{'/askAnswerDetail?answerId='+${list2.getTid()}}"><img src="/static/images/yuedu.png"><span>[[${list2.getRead_num()}]]阅读</span></a></div>
                                <span class="dotted">·</span>
                                <span class="time-before">[[${list2.time}]]</span>
                            </div>
                        </div>
                    </div>

                    <div class="fen-ye"></div>
                </div>
            </div>
            <div class="aside-left margin-t0">
                <div class="wonderful-top">
                    <div class="wonderful-top-title">热搜排行</div>
                    <div class="allsee-item">
                        <ul>
                            <li th:each="list1,itstar:${sou}" th:if="${itstar.count} < 4">
                                <a th:href="@{'/articleDetail?articleId='+${list1.getId()}}">
                                    <span class="other-bg">[[${itstar.count}]]</span><div>[[${list1.getTitle()}]]</div>
                                </a>
                            </li>

                            <li th:each="list1,itstar:${sou}" th:if="${itstar.count} > 3">
                                <a th:href="@{'/articleDetail?articleId='+${list1.getId()}}">
                                    <span>[[${itstar.count}]]</span><div>[[${list1.getTitle()}]]</div>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div th:replace="public::footer"></div>
    <script>
        function getUrlParams(name) { // 不传name返回所有值，否则返回对应值
            var url = window.location.search;
            if (url.indexOf('?') == 1) {
                return false;
            }
            url = url.substr(1);
            url = url.split('&');
            var name = name || '';
            var nameres;
            // 获取全部参数及其值
            for(var i=0;i<url.length;i++) {
                var info = url[i].split('=');
                var obj = {};
                obj[info[0]] = decodeURI(info[1]);
                url[i] = obj;
            }
            // 如果传入一个参数名称，就匹配其值
            if (name) {
                for(var i=0;i<url.length;i++) {
                    for (const key in url[i]) {
                        if (key == name) {
                            nameres = url[i][key];
                        }
                    }
                }
            } else {
                nameres = url;
            }
            // 返回结果
            return nameres;
        }

        $(".search-item-title-10").each(function () {
            var str=$(this).text();
            //alert(str);
            var res1 = getUrlParams('kw');
            console.log(res1);
            var substr= "/"+res1+"/g";
            console.log(substr);
            var replaceStr=str.replace(eval(substr),"<span style='color:#ff0000;font-weight:bold'>"+res1+"</span>");
            console.log(replaceStr);
            $(this).html(replaceStr);
        });


        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?4245936cbef31e434e2b387b56dfd7d8";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();

        var pageCount = [[${mypage.pageAll}]];
        var pageNum = [[${mypage.current}]];
        icon_load(pageCount,pageNum);

        //页面加载时生成按钮
        function icon_load(pageCount,pageNum){
            //生成分页按钮
            if(pageCount > 10){
                pageGroup(pageNum,pageCount);
            }else{
                page_icon(1,pageCount);
            }
        }
        //跳转页面
        function pageGroup(pageNum,pageCount){
            switch(pageNum){
                case 1:
                    page_icon(1,10);
                    break;
                case 2:
                    page_icon(1,10);
                    break;
                case 3:
                    page_icon(1,10);
                    break;
                case 4:
                    page_icon(1,10);
                    break;
                case 5:
                    page_icon(1,10);
                    break;
                case pageCount-3:
                    page_icon(pageCount-9,pageCount);
                    break;
                case pageCount-2:
                    page_icon(pageCount-9,pageCount);
                    break;
                case pageCount-1:
                    page_icon(pageCount-9,pageCount);
                    break;
                case pageCount:
                    page_icon(pageCount-9,pageCount);
                    break;
                default:
                    page_icon(pageNum-4,pageNum+4);
                    break;
            }
        }

        //根据当前选中页生成页面点击按钮
        function page_icon(page,count){
            var currentPage = [[${mypage.current}]];
            var kw = '[[${kw}]]';
            var sum = [[${mypage.pageAll}]];

            var ul_html = "";
            console.log(sum+"---------------"+currentPage);
            if(currentPage > 1){
                ul_html +=  "<div class='fenye-list'><a href=/search?kw="+kw+"&current="+(currentPage-1)+" target='_self'>上一页</a></div>";
            }
            for(var i=page; i<=count; i++){
                if(currentPage == i){
                    ul_html += "<div class='fenye-list'><span class='selected'>"+i+"</span></div>";
                }else{
                    ul_html += "<div class='fenye-list'><a href=/search?kw="+kw+"&page="+i+" target='_self'>"
                        +i+"</a></div>";
                }
            }
            if(currentPage < sum){
                ul_html +=  "<div class='fenye-list'><a href=/search?kw="+kw+"&page="+(currentPage+1)+" target='_self'>下一页</a></div>";
            }
            $(".fen-ye").html(ul_html);
        }
    </script>
</div>
</body>
</html>